#include "Sound.h"

Sound::Sound(){
	for(int h=0;h<-SOUNDS;h++){
		sound[h]=NULL;
	}
	try{
	sound[0]=new CL_SoundBuffer("./resource/jump.wav",false,"wav");
	sound[1]=new CL_SoundBuffer("./resource/step.wav",false,"wav");
	}catch(CL_Exception e){
		printf(e.get_message_and_stack_trace().c_str());
		exit(1);
	}
	lastWalkTime=0;
	lastBonusTime=0;
}

Sound::~Sound(){
	for(int h=0;h<-SOUNDS;h++){
		if(sound[h]){
			delete sound[h];
		}
		sound[h]=NULL;
	}
}

void Sound::soundjump(){
	sound[0]->play();
}

void Sound::soundrun(){
	if(CL_System::get_time()>lastWalkTime+200){
		sound[1]->play();
		lastWalkTime=CL_System::get_time();
	}
}